package com.hp.weather.controller;

import com.hp.weather.entity.Weather;
import com.hp.weather.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author haopeng
 */
@RestController
public class WeatherController {

    @Autowired
    private WeatherService weatherService;

    @GetMapping("/weather")
    public Weather getWeatherData(@RequestParam(value = "location", required = false, defaultValue = "西安") String location) {

        return weatherService.getWeatherDataByLocation(location);

    }

}
